Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

testkit,store/mockstore: make store image to accelerate unit test #42521

Merged
merged 27 commits into from
Jan 5, 2024

Conversation

tiancaiamao
Copy link
Contributor

@tiancaiamao tiancaiamao commented Mar 23, 2023

What problem does this PR solve?

Issue Number: close #42434

Problem Summary:

What is changed and how it works?

In our unit test, almost every test case use

store := testkit.CreateMockStore(t)
tk := testkit.NewTestKit(t, store)

This will create a new mockstore and bootstrap it.
The bootstrap involves a lot of DDL operations, make the test slow.

We can create a bootstraped store as the test image, and later re-use the image to avoid the bootstrap everytime.
Just copy files from the image to get a new bootstraped store for testing.

Check List

Tests

  • Unit test
  • Integration test
  • Manual test (add detailed scripts or steps below)
  • No code

Side effects

  • Performance regression: Consumes more CPU
  • Performance regression: Consumes more Memory
  • Breaking backward compatibility

Documentation

  • Affects user behaviors
  • Contains syntax changes
  • Contains variable changes
  • Contains experimental features
  • Changes MySQL compatibility

Release note

Please refer to Release Notes Language Style Guide to write a quality release note.

None

@ti-chi-bot
Copy link
Member

ti-chi-bot commented Mar 23, 2023

[REVIEW NOTIFICATION]

This pull request has been approved by:

  • lance6716
  • wjhuang2016

To complete the pull request process, please ask the reviewers in the list to review by filling /cc @reviewer in the comment.
After your PR has acquired the required number of LGTMs, you can assign this pull request to the committer in the list by filling /assign @committer in the comment to help you merge this pull request.

The full list of commands accepted by this bot can be found here.

Reviewer can indicate their review by submitting an approval review.
Reviewer can cancel approval by submitting a request changes review.

@ti-chi-bot
Copy link
Member

Skipping CI for Draft Pull Request.
If you want CI signal for your change, please convert it to an actual PR.
You can still manually trigger a test run with /test all

@ti-chi-bot ti-chi-bot added do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. release-note-none Denotes a PR that doesn't merit a release note. size/L Denotes a PR that changes 100-499 lines, ignoring generated files. labels Mar 23, 2023
@tiancaiamao tiancaiamao marked this pull request as ready for review March 23, 2023 10:03
@ti-chi-bot ti-chi-bot removed the do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. label Mar 23, 2023
@tiancaiamao
Copy link
Contributor Author

/test unit-test

3 similar comments
@tiancaiamao
Copy link
Contributor Author

/test unit-test

@tiancaiamao
Copy link
Contributor Author

/test unit-test

@tiancaiamao
Copy link
Contributor Author

/test unit-test

@tiancaiamao
Copy link
Contributor Author

/test unit-test

2 similar comments
@tiancaiamao
Copy link
Contributor Author

/test unit-test

@tiancaiamao
Copy link
Contributor Author

/test unit-test

@tiancaiamao
Copy link
Contributor Author

/test unit-test

2 similar comments
@tiancaiamao
Copy link
Contributor Author

/test unit-test

@tiancaiamao
Copy link
Contributor Author

/test unit-test

@tiancaiamao
Copy link
Contributor Author

/test unit-test

2 similar comments
@tiancaiamao
Copy link
Contributor Author

/test unit-test

@tiancaiamao
Copy link
Contributor Author

/test unit-test

@hawkingrei
Copy link
Member

I find goleak in this PR.

 --- PASS: TestSnapshotWithoutInterceptor (54.52s)
PASS
coverage: 1.1% of statements
goleak: Errors on successful test run: found unexpected goroutines:
[Goroutine 5 in state syscall, with syscall.Syscall on top of the stack:
syscall.Syscall(0x536404b?, 0x0?, 0xa80?, 0x2111160?)
	GOROOT/src/syscall/syscall_linux.go:69 +0x25
syscall.Close(0xc000142560?)
	GOROOT/src/syscall/zsyscall_linux_amd64.go:320 +0x25
internal/poll.(*SysFile).destroy(...)
	GOROOT/src/internal/poll/fd_unixjs.go:24
internal/poll.(*FD).destroy(0xc00168c240)
	GOROOT/src/internal/poll/fd_unix.go:81 +0x51
internal/poll.(*FD).decref(0x7fec68aa4700?)
	GOROOT/src/internal/poll/fd_mutex.go:213 +0x53
internal/poll.(*FD).Close(0xc00168c240)
	GOROOT/src/internal/poll/fd_unix.go:104 +0x45
os.(*file).close(0xc00168c240)
	GOROOT/src/os/file_unix.go:315 +0x98
]
-- 

PTAL @tiancaiamao

@tiancaiamao
Copy link
Contributor Author

I find goleak in this PR.

 --- PASS: TestSnapshotWithoutInterceptor (54.52s)
PASS
coverage: 1.1% of statements
goleak: Errors on successful test run: found unexpected goroutines:
[Goroutine 5 in state syscall, with syscall.Syscall on top of the stack:
syscall.Syscall(0x536404b?, 0x0?, 0xa80?, 0x2111160?)
	GOROOT/src/syscall/syscall_linux.go:69 +0x25
syscall.Close(0xc000142560?)
	GOROOT/src/syscall/zsyscall_linux_amd64.go:320 +0x25
internal/poll.(*SysFile).destroy(...)
	GOROOT/src/internal/poll/fd_unixjs.go:24
internal/poll.(*FD).destroy(0xc00168c240)
	GOROOT/src/internal/poll/fd_unix.go:81 +0x51
internal/poll.(*FD).decref(0x7fec68aa4700?)
	GOROOT/src/internal/poll/fd_mutex.go:213 +0x53
internal/poll.(*FD).Close(0xc00168c240)
	GOROOT/src/internal/poll/fd_unix.go:104 +0x45
os.(*file).close(0xc00168c240)
	GOROOT/src/os/file_unix.go:315 +0x98
]
-- 

PTAL @tiancaiamao

How to reproduce it? I run this test manually but it's ok:

go test -tags intest -run TestSnapshotWithoutInterceptor 
[2024/01/03 13:51:41.145 +08:00] [INFO] [levels.go:70] ["table file not referenced in MANIFEST"] [id=1]
[2024/01/03 13:51:41.240 +08:00] [INFO] [region_cache.go:2741] ["change store resolve state"] [store=1] [addr=store1] [from=unresolved] [to=resolved] [liveness-state=reachable]
[2024/01/03 13:51:41.250 +08:00] [INFO] [db.go:567] ["Closing database"]
[2024/01/03 13:51:41.250 +08:00] [INFO] [db.go:592] ["Memtable flushed"]
[2024/01/03 13:51:41.250 +08:00] [INFO] [db.go:596] ["Compaction finished"]
[2024/01/03 13:51:41.250 +08:00] [INFO] [db.go:615] ["BlobManager finished"]
[2024/01/03 13:51:41.250 +08:00] [INFO] [db.go:619] ["ResourceManager finished"]
[2024/01/03 13:51:41.250 +08:00] [INFO] [db.go:625] ["Waiting for closer"]
PASS
ok      github.com/pingcap/tidb/pkg/store/driver        0.314s 

@tiancaiamao
Copy link
Contributor Author

/test unit-test

Copy link

tiprow bot commented Jan 3, 2024

@tiancaiamao: The specified target(s) for /test were not found.
The following commands are available to trigger required jobs:

  • /test tiprow_fast_test

Use /test all to run all jobs.

In response to this:

/test unit-test

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository.

Copy link

ti-chi-bot bot commented Jan 3, 2024

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: hawkingrei, lance6716, wjhuang2016, xhebox, XuHuaiyu

The full list of commands accepted by this bot can be found here.

The pull request process is described here

Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@ti-chi-bot ti-chi-bot bot added approved lgtm and removed needs-1-more-lgtm Indicates a PR needs 1 more LGTM. labels Jan 3, 2024
Copy link

ti-chi-bot bot commented Jan 3, 2024

[LGTM Timeline notifier]

Timeline:

  • 2023-06-12 12:54:45.563535635 +0000 UTC m=+3881.978139713: ✖️🔁 reset by tiancaiamao.
  • 2024-01-02 01:38:32.927893714 +0000 UTC m=+2134603.965120655: ☑️ agreed by xhebox.
  • 2024-01-03 06:23:19.33757022 +0000 UTC m=+2238090.374797147: ☑️ agreed by XuHuaiyu.

@tiancaiamao
Copy link
Contributor Author

/test unit-test

Copy link

tiprow bot commented Jan 3, 2024

@tiancaiamao: The specified target(s) for /test were not found.
The following commands are available to trigger required jobs:

  • /test tiprow_fast_test

Use /test all to run all jobs.

In response to this:

/test unit-test

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository.

@tiancaiamao
Copy link
Contributor Author

/test unit-test

Copy link

tiprow bot commented Jan 3, 2024

@tiancaiamao: The specified target(s) for /test were not found.
The following commands are available to trigger required jobs:

  • /test tiprow_fast_test

Use /test all to run all jobs.

In response to this:

/test unit-test

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository.

@tiancaiamao
Copy link
Contributor Author

/test tiprow_fast_test

Copy link

ti-chi-bot bot commented Jan 3, 2024

@tiancaiamao: The specified target(s) for /test were not found.
The following commands are available to trigger required jobs:

  • /test build
  • /test check-dev
  • /test check-dev2
  • /test mysql-test
  • /test pull-integration-ddl-test
  • /test pull-lightning-integration-test
  • /test pull-mysql-client-test
  • /test unit-test

The following commands are available to trigger optional jobs:

  • /test canary-notify-when-compatibility-sections-changed
  • /test pingcap/tidb/canary_ghpr_unit_test
  • /test pull-br-integration-test
  • /test pull-common-test
  • /test pull-e2e-test
  • /test pull-integration-common-test
  • /test pull-integration-copr-test
  • /test pull-integration-jdbc-test
  • /test pull-integration-mysql-test
  • /test pull-integration-nodejs-test
  • /test pull-sqllogic-test
  • /test pull-tiflash-test

Use /test all to run the following jobs that were automatically triggered:

  • pingcap/tidb/ghpr_build
  • pingcap/tidb/ghpr_check
  • pingcap/tidb/ghpr_check2
  • pingcap/tidb/ghpr_mysql_test
  • pingcap/tidb/ghpr_unit_test
  • pingcap/tidb/pull_integration_ddl_test
  • pingcap/tidb/pull_mysql_client_test

In response to this:

/test tiprow_fast_test

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository.

Copy link

tiprow bot commented Jan 3, 2024

@tiancaiamao: The following test failed, say /retest to rerun all failed tests or /retest-required to rerun all mandatory failed tests:

Test name Commit Details Required Rerun command
tiprow_fast_test cce19c4 link true /test tiprow_fast_test

Full PR test history. Your PR dashboard.

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository. I understand the commands that are listed here.

@tiancaiamao
Copy link
Contributor Author

/test unit-test

Copy link

tiprow bot commented Jan 3, 2024

@tiancaiamao: The specified target(s) for /test were not found.
The following commands are available to trigger required jobs:

  • /test tiprow_fast_test

Use /test all to run all jobs.

In response to this:

/test unit-test

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository.

@ti-chi-bot ti-chi-bot bot merged commit 6eea739 into pingcap:master Jan 5, 2024
19 of 20 checks passed
@tiancaiamao tiancaiamao deleted the issue-42434 branch January 5, 2024 12:27
hawkingrei added a commit that referenced this pull request Jan 8, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
approved component/dumpling This is related to Dumpling of TiDB. lgtm ok-to-test Indicates a PR is ready to be tested. release-note-none Denotes a PR that doesn't merit a release note. size/L Denotes a PR that changes 100-499 lines, ignoring generated files. status/can-merge Indicates a PR has been approved by a committer. status/LGT2 Indicates that a PR has LGTM 2.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

CI timeout due to bootstrap is very slow
8 participants